<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    // 该部分主要用于验证浏览器和node端不同的变量提升特性
    console.log(window.a, a); //undefined undefined
    {
      console.log(window.a, a); //undefined function a(){}
      function a() {}
      //   因为只有window.a只有等块级作用域中函数声明的定义的那行代码执行过之后，才会被映射到全局作用域，相当于仅执行了window.a = a，即便此时a可能并不是function了
      console.log(window.a, a); //function a(){} function a(){}
    }
    console.log(window.a, a); //function a(){} function a(){}

    console.log("----------分割线----------");

    {
      console.log(window.b, b); //undefined function b(){}
      function b() {}
      console.log(window.b, b); //function b(){}  function b(){}
      b = 10;
      console.log(window.b, b); //function b(){}  10
    }
    console.log(window.b, b); //function b(){}  function b(){}
  </script>
</html>
